
export const chartOption = {
  title: {
    text: '',
    x: 'center',
    y: 'top',
    textStyle: {
      fontSize: 16,
      color: '#fff'
    },
    top: "10",
  },
  grid: {
    top: '20%',
    right: '3%',
    bottom: '13%',
    left: '60'
  },
  tooltip: {
    trigger: 'axis',
  },
  legend: {
    textStyle: {
      color: '#666'
    },
    top: "40",
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    data: [],
    axisLabel: {
      formatter: (value) =>  //X轴的内容
      {

        let ret = ""; //拼接加\n返回的类目项
        let max = 10;  //每行显示的文字字数
        let val = value.length;  //X轴内容的文字字数
        let rowN = Math.ceil(val / max);  //需要换的行数
        if (rowN > 1)  //判断 如果字数大于2就换行
        {
          for (let i = 0; i < rowN; i++) {
            let temp = "";  //每次截取的字符串
            let start = i * max;  //开始截取的位置
            let end = start + max;  //结束截取的位置
            temp = value.substring(start, end) + "\n";
            ret += temp;  //最终的字符串
          }
          return ret;
        }
        else { return value }
      }
    }
  },
  yAxis: {
    type: 'value'
  },
  dataZoom: [
    {
      type: "inside",
      xAxisIndex: [0, 1],
      start: 0,
      end: 100,
    },
    {
      show: true,
      type: "slider",
      xAxisIndex: [0, 1],
      start: 0,
      end: 100,
      height: 20,
      bottom: 10,
      borderColor: "#ccc",
      fillerColor: "rgba(167,183,204,0.4)",
      handleColor: "#fff",
      handleSize: "100%",
    },
  ],
  series: [{
    data: [],
    type: 'line',
    symbol: 'circle',
    itemStyle: {
      normal: {
        color: '#f9ca59', //改变折线点的颜色
        lineStyle: {
          color: '#f9ca59' //改变折线颜色
        }
      }
    },
    areaStyle: {
      color: {
        type: 'linear',
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [{
          offset: 0, color: 'rgba(249,202,89,0.3)' // 0% 处的颜色
        }, {
          offset: 1, color: 'rgba(249,202,89,0.3)' // 100% 处的颜色
        }],
        global: false // 缺省为 false
      }
    }
  }, {
    data: [],
    type: 'line',
    symbol: 'circle',
    itemStyle: {
      normal: {
        color: '#76c0de', //改变折线点的颜色
        lineStyle: {
          color: '#76c0de' //改变折线颜色
        }
      }
    },
    areaStyle: {
      color: {
        type: 'linear',
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [{
          offset: 0, color: 'rgba(118,192,222, 1)' // 0% 处的颜色
        }, {
          offset: 1, color: 'rgba(118,192,222, 0)' // 100% 处的颜色
        }],
        global: false // 缺省为 false
      }
    }
  }]
};
